package util;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import tools.BufferTools;

public class LightingOptions
{
	public FloatBuffer diffuse;      // color of the lit surface
	public FloatBuffer ambient;      // color of the shadowed surface
	public FloatBuffer specular;     // reflection color (typically this is a shade of gray)
	public FloatBuffer emission;     // glow color
	public FloatBuffer shininess;    // size of the reflection highlight
	
//	float pos[] = new float[]{50.0f, 30.0f, 100.0f, 1.0f};
	float pos[] = new float[]{0.0f, 0.0f, 0.0f, 1.0f};
	public FloatBuffer position;
	
	public LightingOptions()
	{
		diffuse = BufferTools.asFlippedFloatBuffer(GLColor.clrDefaultDiffuse);
		ambient = BufferTools.asFlippedFloatBuffer(GLColor.clrDefaultAmbient);
		specular = BufferTools.asFlippedFloatBuffer(GLColor.clrNone);
		emission = BufferTools.asFlippedFloatBuffer(GLColor.clrNone);
		shininess = BufferTools.asFlippedFloatBuffer(new float[] {GLColor.shineMin,0,0,0});
		position = BufferTools.asFlippedFloatBuffer(pos);
	}
	
	public void setDiffuse(float[] color) { diffuse = BufferTools.asFlippedFloatBuffer(color); }
	public void setAmbient(float[] color) { ambient = BufferTools.asFlippedFloatBuffer(color); }
	public void setSpecular(float[] color) { specular = BufferTools.asFlippedFloatBuffer(color); }
	public void setEmission(float[] color) { emission = BufferTools.asFlippedFloatBuffer(color); }
	public void setShininess(float value)
	{ 
		if (value < GLColor.shineMin) value = GLColor.shineMin;
		if (value > GLColor.shineMax) value = GLColor.shineMax;
		shininess = BufferTools.asFlippedFloatBuffer(new float[] {value,0,0,0});
	}
}
